package com.shanzmoo.h5.domain.req;

import com.shanzmoo.base.constant.PayStatusConstant;
import com.shanzmoo.base.constant.e.PayTypeEnum;
import com.shanzmoo.base.util.BillNoUtils;
import com.shanzmoo.db.trade.entity.PayOrderEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;

/**
 * 扫描用户的付款码，收款请求信息
 *
 * @author: Gzhao 2020/12/10
 */
@Data
@ApiModel("扫描用户付款码，收款请求信息")
public class PayOrderTradeReq implements Serializable {
    private static final long serialVersionUID = 1758L;

    @NotNull
    @ApiModelProperty(value = "支付类型", example = "Wx")
    private PayTypeEnum payType;

    @NotBlank
    @ApiModelProperty(value = "付款条码", example = "1345 0904 0138 919255")
    private String authCode;

    @NotBlank
    @ApiModelProperty(value = "订单号", example = "MA202012112353489319")
    private String orderNo;

    @NotBlank
    @ApiModelProperty(value = "商品描述", example = "扫码测试订单")
    private String body;

    @NotNull
    @ApiModelProperty(value = "支付金额(分)", example = "1")
    private Integer payAmount;

    @NotNull
    @ApiModelProperty(value = "终端IP", example = "123.12.12.123")
    private String ip;

    @NotNull
    @ApiModelProperty(value = "门店id", example = "1")
    private Integer storeId;

    public PayOrderEntity convertToPayOrderEntity() {
        return PayOrderEntity.builder()
                .type(payType.getCode())
                .payNo(BillNoUtils.generatePayNo())
                .orderNo(orderNo)
                .payStatus(PayStatusConstant.WAIT_PAY)
                .body(body)
                .totalFee(payAmount)
                .feeType("CNY")
                .ip(ip)
                .outletId(storeId)
                .build();
    }

}
